Skip to content

Adding warning callback handlers and isAsync detection #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2025

Conversation

fabisev
Copy link
Contributor

@fabisev fabisev commented Jul 16, 2025

Issue #, if available:

Description of changes:

  1. Added warning message for Lambda functions using callback-based handlers:

    • Warning appears when handler has 3 arguments, is not async, and is not streaming
    • Warning can be disabled by setting AWS_LAMBDA_NODEJS_DISABLE_CALLBACK_WARNING environment variable
    • Added unit tests to verify warning behavior across different handler types
  2. Added detection and handling of unresolved promises in async Lambda functions:

    • Introduced NodejsExit error class with descriptive message about unresolved promises
    • Added isAsync detection to identify async Lambda handlers
    • Modified exit listener behavior to fail invocations for async handlers with unresolved promises
    • Maintained existing behavior for sync/callback handlers
    • Added unit tests to verify async handler detection

Target (OCI, Managed Runtime, both):
both

Checklist

  • I have run npm install to generate the package-lock.json correctly and included it in the PR.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fabiana Severin and others added 3 commits July 16, 2025 15:55
@@ -0,0 +1,17 @@
/** Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we use this or:

/*
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

src/WarningForCallbackHandlers.js has the other licence line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! let's use the later as it's year-agnostic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to merge after this change @fabisev

Copy link
Member

@godcrampy godcrampy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left a nit.

@fabisev fabisev merged commit b4e31e1 into main Aug 13, 2025
3 checks passed
@fabisev fabisev deleted the fabisev/warning-callback-handlers branch August 13, 2025 09:24
@fabisev fabisev restored the fabisev/warning-callback-handlers branch August 13, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants